﻿using System.IO;
using Ninject;
using NUnit.Framework;

using System.Net.DnsToolkit.Packet;
using System.Net.DnsToolkit.Serializer;
using System.Net.DnsToolkit.Configuration;
using System.Net.DnsToolkit.Bastard.PacketGenerator;
using System.Net.DnsToolkit.Util;

namespace System.Net.DnsToolkit.TestUnit.Bastard.PacketGenerator {

    [TestFixture]
    public class SingleQuestionTest {

        [Test]
        public void TestGetMessage() {

            var generator = new SingleQuestion();
            var message = generator.GetMessage();

            Assert.AreEqual(1, message.Questions.Count, "Questions.Count");
            Assert.AreEqual(1, message.Header.QuestionCount, "Header.QuestionCount");
            Assert.AreEqual("darkdns.codeplex.com", message.Questions[0].QName.Name, "darkdns.codeplex.com.");
        }

        [Test]
        public void TestGetBytes() {


            var generator = new SingleQuestion();
            byte[] bs = generator.GetBytes();
            Assert.AreEqual(38, bs.Length, "length");

            string bstring = BitStringHelper.ByteArrayToString(bs);
            Assert.AreEqual("000000000001000000000000076461726B646E7308636F6465706C657803636F6D0000010001", bstring, "representation");

        }

    }
}
